#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n;
    cin >> n;
    string s[n];
    unordered_map<int, vector<int>>pos;
    for(int i = 0; i < n; i++)
    {
        cin >> s[i];
        pos[s[i].size()].push_back(i);
    }
    long long res = 0;
    for(int i = 1; i <= 5; i++)
    {
        for(int j = 1; j <= 5; j++)
        {
            if((i + j) & 1) continue;
            int mid = (i + j) / 2;
            unordered_map<int, int> mp;
            for(auto x : pos[i])
            {
                int sum = 0;
                for(int k = 0; k < s[x].size(); k++)
                {
                    if(k >= mid)
                    {
                        sum -= (s[x][k] - '0');
                    }
                    else sum += (s[x][k] - '0');
                }
                mp[sum]++;
            }
            for(auto x : pos[j])
            {
                int sum = 0;
                for(int k = 0; k < s[x].size(); k++)
                {
                    if(k + i + 1 <= mid)
                    {
                        sum -= (s[x][k] - '0');
                    }
                    else sum += (s[x][k] - '0');
                }
                res += mp[sum];
            }
        }
    }
    cout << res << endl;
    return 0;
}